﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CardInChina.Data.Entity.Interface;
using CardInChina.Data.Entity.Entity;

namespace CardInChina.Bussiness.Frontend.Interface
{
    public class ExchangeBusinessService
    {
        ExchangeService es = new ExchangeService();
        CardService cs = new CardService();

        private static double Base_Rate = 1.35;

        public double GetCommomPriceOfCardByExchange(Card card , int currency_type)
        {
            if (currency_type != 8)//non RMB
                return es.GetExchangeValueFromRMB((double)card.Price, currency_type) * Base_Rate;
            else
                return es.GetExchangeValueFromRMB((double)card.Price, currency_type);
        }

        public double GetCommomPriceOfCardByExchange(int cardId, int currency_type)
        {
            Card c = cs.GetCardEntityByCardID(cardId);
            if (c == null)
                throw new Exception("card not found");
            else
                return GetCommomPriceOfCardByExchange(c, currency_type);
        }

        public double GetVIPPriceOfCardByExchange(Card card, int currency_type)
        {
            if (currency_type != 8)//non RMB
                return es.GetExchangeValueFromRMB((double)card.VIPPrice, currency_type) * Base_Rate;
            else
                return es.GetExchangeValueFromRMB((double)card.VIPPrice, currency_type);
        }

        public double GetVIPPriceOfCardByExchange(int cardId, int currency_type)
        {
            Card c = cs.GetCardEntityByCardID(cardId);
            if (c == null)
                throw new Exception("card not found");
            else
                return GetVIPPriceOfCardByExchange(c, currency_type);
        }


        public Exchange GetExchangeEntityByExchangeID(int id)
        {
            return es.GetExchangeEntityByExchangeID(id);
 
        }
    }
}
